home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000107_icon-group-sender _Wed Apr 9 15:06:07 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Thu, 10 Apr 1997 12:33:56 MST
Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
id AA00534; Thu, 10 Apr 1997 12:33:56 -0700
Sender: rpereda@micro.ti.com
Message-Id: <334BF6AF.485EBC12@micro.ti.com>
Date: Wed, 09 Apr 1997 15:06:07 -0500
From: Ray Pereda <rpereda@micro.ti.com>
Organization: Texas Instruments
X-Mailer: Mozilla 3.0Gold (X11; I; SunOS 4.1.4 sun4m)
Mime-Version: 1.0
To: Eka Laiman <eka@corp.cirrus.com>
Cc: Kostas Oikonomou <ko@surya.ho.att.com>, icon-group@cs.arizona.edu
Subject: Re: Problem with Icon 9.3
References: <9704082058.AA18878@ss492.corp.cirrus.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 2489
Kka,
Indexing table by say an integer is different than indexing by a list.
An integer is treated like a value. One integer 3 is the same as
another integer 3. A list is treated more like an object. ["q0", "ok"]
could generate a list object in one part of the code. ["q0", "ok"]
generates an entirely new list in another place in the code. When a
list a created, an anonymous name or tag is also created. This
anonymous tag is what is really indexing the table.
If you want to index by some value then you need to translate the list
into some unique string, and then use that string to index.
What do you think about making tables index-able by either values or
objects?
link ximage
procedure main()
sd := table([], "object")
sd[[1]] := 1
sd[[1]] := 2
every write(ximage(sd))
end
would produce
T1 := table({L1 := list(0)
L1})
T1[{L2 := list(1)
L2[1] := 1
L2}] := 1
T1[{L3 := list(1)
L3[1] := 1
L3}] := 2
and
link ximage
procedure main()
sd := table([], "value")
sd[[1]] := 1
sd[[1]] := 2
every write(ximage(sd))
end
T1 := table({L1 := list(0)
L1})
T1[{L2 := list(1)
L2[1] := 1
L2}] := 2
-Ray Pereda
Eka Laiman wrote:
>
> > I have the following simple (I think) program:
> >
> > link ximage
> >
> > procedure main()
> >
> > # The state diagram.
> > sd := table([])
> > sd[["q0","ok"]] := "q1"
> > sd[["q0","nok"]] := "q0"
> > sd[["q1","nok"]] := "q0"
> > sd[["q1","ok"]] := "q2"
> > # q2 is the final state
> >
> > every x := key(sd) do write(ximage(x), ":", sd[x])
> >
> > end
> >
> > This doesn't behave as I think it should. The problem seems to be a
> > table whose keys are lists. Is there something wrong with this kind of
> > structure? I don't see anything to that effect in the 3d edition of the
> > Icon book, Ch. 6 on tables.
>
> Wow, indexing using "list"s?
>
> I do not know if ICON's tables are built with this kind of operation in
> mind. I personally think that ICON tables are like "hash table" where the
> indexing can be done using both "strings" or "integers". According to the
> definition: "Tables resemble lists, except that the keys, or 'subscripts',
> need not be integers but can be *values of any type*." I have not tried to
> do indexing based on "float" yet, although theoretically that's possible
> :-)
>
> If I were you, I would first convert the list into "string" and use the
> resulting string as the key.
>
> -eka-